home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 January: Mac OS SDK / Dev.CD Jan 98 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / AIncludes / Unicode.a < prev    next >
Encoding:
Text File  |  1997-08-12  |  12.1 KB  |  331 lines  |  [TEXT/MPS ]

  1. ;
  2. ;    File:        Unicode.a
  3. ;
  4. ;    Contains:    Types, constants, and prototypes for Unicode Converter
  5. ;
  6. ;    Version:    Technology:    Mac OS 8 (Tempo)
  7. ;                Release:    Universal Interfaces 3.0.1
  8. ;
  9. ;    Copyright:    © 1994-1997 by Apple Computer, Inc., all rights reserved.
  10. ;
  11. ;    Bugs?:        Please include the the file and version information (from above) with
  12. ;                the problem description.  Developers belonging to one of the Apple
  13. ;                developer programs can submit bug reports to:
  14. ;
  15. ;                    devsupport@apple.com
  16. ;
  17. ;
  18.     IF &TYPE('__UNICODE__') = 'UNDEFINED' THEN
  19. __UNICODE__ SET 1
  20.  
  21.     IF &TYPE('__TYPES__') = 'UNDEFINED' THEN
  22.     include 'Types.a'
  23.     ENDIF
  24.     IF &TYPE('__TEXTCOMMON__') = 'UNDEFINED' THEN
  25.     include 'TextCommon.a'
  26.     ENDIF
  27.     IF &TYPE('__MIXEDMODE__') = 'UNDEFINED' THEN
  28.     include 'MixedMode.a'
  29.     ENDIF
  30.  
  31. ;  Unicode conversion contexts: 
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38. ;  UnicodeMapVersion type & values 
  39. ; typedef SInt32                         UnicodeMapVersion
  40.  
  41.  
  42. kUnicodeUseLatestMapping        EQU        -1
  43. ;  Types used in conversion 
  44. UnicodeMapping            RECORD 0
  45. unicodeEncoding             ds.l    1                ; offset: $0 (0)
  46. otherEncoding             ds.l    1                ; offset: $4 (4)
  47. mappingVersion             ds.l    1                ; offset: $8 (8)
  48. sizeof                     EQU *                    ; size:   $C (12)
  49.                         ENDR
  50. ; typedef struct UnicodeMapping *        UnicodeMappingPtr
  51.  
  52. ; typedef const struct UnicodeMapping *    ConstUnicodeMappingPtr
  53.  
  54. ;  Control flags for ConvertFromUnicodeToText and ConvertFromTextToUnicode 
  55.  
  56. kUnicodeUseFallbacksBit            EQU        0
  57. kUnicodeKeepInfoBit                EQU        1
  58. kUnicodeDirectionalityBits        EQU        2
  59. kUnicodeVerticalFormBit            EQU        4
  60. kUnicodeLooseMappingsBit        EQU        5
  61. kUnicodeStringUnterminatedBit    EQU        6
  62. kUnicodeTextRunBit                EQU        7
  63. kUnicodeKeepSameEncodingBit        EQU        8
  64.  
  65. kUnicodeUseFallbacksMask        EQU        $00000001
  66. kUnicodeKeepInfoMask            EQU        $00000002
  67. kUnicodeDirectionalityMask        EQU        $0000000C
  68. kUnicodeVerticalFormMask        EQU        $00000010
  69. kUnicodeLooseMappingsMask        EQU        $00000020
  70. kUnicodeStringUnterminatedMask    EQU        $00000040
  71. kUnicodeTextRunMask                EQU        $00000080
  72. kUnicodeKeepSameEncodingMask    EQU        $00000100
  73. ;  Values for kUnicodeDirectionality field 
  74.  
  75. kUnicodeDefaultDirection        EQU        0
  76. kUnicodeLeftToRight                EQU        1
  77. kUnicodeRightToLeft                EQU        2
  78. ;  Directionality masks for control flags 
  79.  
  80. kUnicodeDefaultDirectionMask    EQU        $00
  81. kUnicodeLeftToRightMask            EQU        $04
  82. kUnicodeRightToLeftMask            EQU        $08
  83. ;  Control flags for TruncateForUnicodeToText: 
  84.  
  85. ;   Now TruncateForUnicodeToText uses control flags from the same set as used by
  86. ;   ConvertFromTextToUnicode, ConvertFromUnicodeToText, etc., but only
  87. ;   kUnicodeStringUnterminatedMask is meaningful for TruncateForUnicodeToText.
  88. ;   
  89. ;   Previously two special control flags were defined for TruncateForUnicodeToText:
  90. ;          kUnicodeTextElementSafeBit = 0
  91. ;          kUnicodeRestartSafeBit = 1
  92. ;   However, neither of these was implemented.
  93. ;   Instead of implementing kUnicodeTextElementSafeBit, we now use
  94. ;   kUnicodeStringUnterminatedMask since it accomplishes the same thing and avoids
  95. ;   having special flags just for TruncateForUnicodeToText
  96. ;   Also, kUnicodeRestartSafeBit is unnecessary, since restart-safeness is handled by
  97. ;   setting kUnicodeKeepInfoBit with ConvertFromUnicodeToText.
  98. ;   If TruncateForUnicodeToText is called with one or both of the old special control
  99. ;   flags set (bits 0 or 1), it will not generate a paramErr, but the old bits have no
  100. ;   effect on its operation.
  101.  
  102.  
  103.  
  104. ;  Filter bits for filter field in QueryUnicodeMappings and CountUnicodeMappings: 
  105.  
  106. kUnicodeMatchUnicodeBaseBit        EQU        0
  107. kUnicodeMatchUnicodeVariantBit    EQU        1
  108. kUnicodeMatchUnicodeFormatBit    EQU        2
  109. kUnicodeMatchOtherBaseBit        EQU        3
  110. kUnicodeMatchOtherVariantBit    EQU        4
  111. kUnicodeMatchOtherFormatBit        EQU        5
  112.  
  113. kUnicodeMatchUnicodeBaseMask    EQU        $00000001
  114. kUnicodeMatchUnicodeVariantMask    EQU        $00000002
  115. kUnicodeMatchUnicodeFormatMask    EQU        $00000004
  116. kUnicodeMatchOtherBaseMask        EQU        $00000008
  117. kUnicodeMatchOtherVariantMask    EQU        $00000010
  118. kUnicodeMatchOtherFormatMask    EQU        $00000020
  119. ;  Control flags for SetFallbackUnicodeToText 
  120.  
  121. kUnicodeFallbackSequencingBits    EQU        0
  122.  
  123. kUnicodeFallbackSequencingMask    EQU        $00000003
  124. ;  values for kUnicodeFallbackSequencing field 
  125.  
  126. kUnicodeFallbackDefaultOnly        EQU        0
  127. kUnicodeFallbackCustomOnly        EQU        1
  128. kUnicodeFallbackDefaultFirst    EQU        2
  129. kUnicodeFallbackCustomFirst        EQU        3
  130.  
  131. ;  Caller-supplied entry point to a fallback handler 
  132. ;  Function prototypes 
  133.     IF GENERATING68K THEN
  134. ;  Rounite to Initialize the Unicode Converter and cleanup once done with it 
  135. ;
  136. ; pascal OSStatus InitializeUnicode(StringPtr TECFileName)
  137. ;
  138.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  139.         IMPORT_CFM_FUNCTION InitializeUnicode
  140.     ENDIF
  141.  
  142. ;
  143. ; pascal void TerminateUnicode(void )
  144. ;
  145.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  146.         IMPORT_CFM_FUNCTION TerminateUnicode
  147.     ENDIF
  148.  
  149.     ENDIF    ; GENERATING68K
  150. ;
  151. ; pascal OSStatus CreateTextToUnicodeInfo(ConstUnicodeMappingPtr iUnicodeMapping, TextToUnicodeInfo *oTextToUnicodeInfo)
  152. ;
  153.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  154.         IMPORT_CFM_FUNCTION CreateTextToUnicodeInfo
  155.     ENDIF
  156.  
  157. ;
  158. ; pascal OSStatus CreateTextToUnicodeInfoByEncoding(TextEncoding iEncoding, TextToUnicodeInfo *oTextToUnicodeInfo)
  159. ;
  160.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  161.         IMPORT_CFM_FUNCTION CreateTextToUnicodeInfoByEncoding
  162.     ENDIF
  163.  
  164. ;
  165. ; pascal OSStatus CreateUnicodeToTextInfo(ConstUnicodeMappingPtr iUnicodeMapping, UnicodeToTextInfo *oUnicodeToTextInfo)
  166. ;
  167.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  168.         IMPORT_CFM_FUNCTION CreateUnicodeToTextInfo
  169.     ENDIF
  170.  
  171. ;
  172. ; pascal OSStatus CreateUnicodeToTextInfoByEncoding(TextEncoding iEncoding, UnicodeToTextInfo *oUnicodeToTextInfo)
  173. ;
  174.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  175.         IMPORT_CFM_FUNCTION CreateUnicodeToTextInfoByEncoding
  176.     ENDIF
  177.  
  178. ;
  179. ; pascal OSStatus CreateUnicodeToTextRunInfo(ItemCount iNumberOfMappings, const UnicodeMapping iUnicodeMappings[2147483647], UnicodeToTextRunInfo *oUnicodeToTextInfo)
  180. ;
  181.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  182.         IMPORT_CFM_FUNCTION CreateUnicodeToTextRunInfo
  183.     ENDIF
  184.  
  185. ;
  186. ; pascal OSStatus CreateUnicodeToTextRunInfoByEncoding(ItemCount iNumberOfEncodings, const TextEncoding iEncodings[2147483647], UnicodeToTextRunInfo *oUnicodeToTextInfo)
  187. ;
  188.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  189.         IMPORT_CFM_FUNCTION CreateUnicodeToTextRunInfoByEncoding
  190.     ENDIF
  191.  
  192. ;
  193. ; pascal OSStatus CreateUnicodeToTextRunInfoByScriptCode(ItemCount iNumberOfScriptCodes, const ScriptCode iScripts[2147483647], UnicodeToTextRunInfo *oUnicodeToTextInfo)
  194. ;
  195.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  196.         IMPORT_CFM_FUNCTION CreateUnicodeToTextRunInfoByScriptCode
  197.     ENDIF
  198.  
  199. ;  Change the TextToUnicodeInfo to another mapping. 
  200. ;
  201. ; pascal OSStatus ChangeTextToUnicodeInfo(TextToUnicodeInfo ioTextToUnicodeInfo, ConstUnicodeMappingPtr iUnicodeMapping)
  202. ;
  203.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  204.         IMPORT_CFM_FUNCTION ChangeTextToUnicodeInfo
  205.     ENDIF
  206.  
  207. ;  Change the UnicodeToTextInfo to another mapping. 
  208. ;
  209. ; pascal OSStatus ChangeUnicodeToTextInfo(UnicodeToTextInfo ioUnicodeToTextInfo, ConstUnicodeMappingPtr iUnicodeMapping)
  210. ;
  211.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  212.         IMPORT_CFM_FUNCTION ChangeUnicodeToTextInfo
  213.     ENDIF
  214.  
  215. ;
  216. ; pascal OSStatus DisposeTextToUnicodeInfo(TextToUnicodeInfo *ioTextToUnicodeInfo)
  217. ;
  218.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  219.         IMPORT_CFM_FUNCTION DisposeTextToUnicodeInfo
  220.     ENDIF
  221.  
  222. ;
  223. ; pascal OSStatus DisposeUnicodeToTextInfo(UnicodeToTextInfo *ioUnicodeToTextInfo)
  224. ;
  225.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  226.         IMPORT_CFM_FUNCTION DisposeUnicodeToTextInfo
  227.     ENDIF
  228.  
  229. ;
  230. ; pascal OSStatus DisposeUnicodeToTextRunInfo(UnicodeToTextRunInfo *ioUnicodeToTextRunInfo)
  231. ;
  232.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  233.         IMPORT_CFM_FUNCTION DisposeUnicodeToTextRunInfo
  234.     ENDIF
  235.  
  236. ;
  237. ; pascal OSStatus ConvertFromTextToUnicode(TextToUnicodeInfo iTextToUnicodeInfo, ByteCount iSourceLen, ConstLogicalAddress iSourceStr, OptionBits iControlFlags, ItemCount iOffsetCount, ByteOffset iOffsetArray[2147483647], ItemCount *oOffsetCount, ByteOffset oOffsetArray[2147483647], ByteCount iOutputBufLen, ByteCount *oSourceRead, ByteCount *oUnicodeLen, UniCharArrayPtr oUnicodeStr)
  238. ;
  239.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  240.         IMPORT_CFM_FUNCTION ConvertFromTextToUnicode
  241.     ENDIF
  242.  
  243. ;
  244. ; pascal OSStatus ConvertFromUnicodeToText(UnicodeToTextInfo iUnicodeToTextInfo, ByteCount iUnicodeLen, ConstUniCharArrayPtr iUnicodeStr, OptionBits iControlFlags, ItemCount iOffsetCount, ByteOffset iOffsetArray[2147483647], ItemCount *oOffsetCount, ByteOffset oOffsetArray[2147483647], ByteCount iOutputBufLen, ByteCount *oInputRead, ByteCount *oOutputLen, LogicalAddress oOutputStr)
  245. ;
  246.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  247.         IMPORT_CFM_FUNCTION ConvertFromUnicodeToText
  248.     ENDIF
  249.  
  250. ;
  251. ; pascal OSStatus ConvertFromUnicodeToTextRun(UnicodeToTextRunInfo iUnicodeToTextInfo, ByteCount iUnicodeLen, ConstUniCharArrayPtr iUnicodeStr, OptionBits iControlFlags, ItemCount iOffsetCount, ByteOffset iOffsetArray[2147483647], ItemCount *oOffsetCount, ByteOffset oOffsetArray[2147483647], ByteCount iOutputBufLen, ByteCount *oInputRead, ByteCount *oOutputLen, LogicalAddress oOutputStr, ItemCount iEncodingRunBufLen, ItemCount *oEncodingRunOutLen, TextEncodingRun oEncodingRuns[2147483647])
  252. ;
  253.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  254.         IMPORT_CFM_FUNCTION ConvertFromUnicodeToTextRun
  255.     ENDIF
  256.  
  257. ;
  258. ; pascal OSStatus ConvertFromUnicodeToScriptCodeRun(UnicodeToTextRunInfo iUnicodeToTextInfo, ByteCount iUnicodeLen, ConstUniCharArrayPtr iUnicodeStr, OptionBits iControlFlags, ItemCount iOffsetCount, ByteOffset iOffsetArray[2147483647], ItemCount *oOffsetCount, ByteOffset oOffsetArray[2147483647], ByteCount iOutputBufLen, ByteCount *oInputRead, ByteCount *oOutputLen, LogicalAddress oOutputStr, ItemCount iScriptRunBufLen, ItemCount *oScriptRunOutLen, ScriptCodeRun oScriptCodeRuns[2147483647])
  259. ;
  260.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  261.         IMPORT_CFM_FUNCTION ConvertFromUnicodeToScriptCodeRun
  262.     ENDIF
  263.  
  264. ;  Truncate a multibyte string at a safe place. 
  265. ;
  266. ; pascal OSStatus TruncateForTextToUnicode(ConstTextToUnicodeInfo iTextToUnicodeInfo, ByteCount iSourceLen, ConstLogicalAddress iSourceStr, ByteCount iMaxLen, ByteCount *oTruncatedLen)
  267. ;
  268.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  269.         IMPORT_CFM_FUNCTION TruncateForTextToUnicode
  270.     ENDIF
  271.  
  272. ;  Truncate a Unicode string at a safe place. 
  273. ;
  274. ; pascal OSStatus TruncateForUnicodeToText(ConstUnicodeToTextInfo iUnicodeToTextInfo, ByteCount iSourceLen, ConstUniCharArrayPtr iSourceStr, OptionBits iControlFlags, ByteCount iMaxLen, ByteCount *oTruncatedLen)
  275. ;
  276.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  277.         IMPORT_CFM_FUNCTION TruncateForUnicodeToText
  278.     ENDIF
  279.  
  280. ;  Convert a Pascal string to Unicode string. 
  281. ;
  282. ; pascal OSStatus ConvertFromPStringToUnicode(TextToUnicodeInfo iTextToUnicodeInfo, ConstStr255Param iPascalStr, ByteCount iOutputBufLen, ByteCount *oUnicodeLen, UniCharArrayPtr oUnicodeStr)
  283. ;
  284.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  285.         IMPORT_CFM_FUNCTION ConvertFromPStringToUnicode
  286.     ENDIF
  287.  
  288. ;  Convert a Unicode string to Pascal string. 
  289. ;
  290. ; pascal OSStatus ConvertFromUnicodeToPString(UnicodeToTextInfo iUnicodeToTextInfo, ByteCount iUnicodeLen, ConstUniCharArrayPtr iUnicodeStr, Str255 oPascalStr)
  291. ;
  292.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  293.         IMPORT_CFM_FUNCTION ConvertFromUnicodeToPString
  294.     ENDIF
  295.  
  296. ;  Count the available conversion mappings. 
  297. ;
  298. ; pascal OSStatus CountUnicodeMappings(OptionBits iFilter, ConstUnicodeMappingPtr iFindMapping, ItemCount *oActualCount)
  299. ;
  300.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  301.         IMPORT_CFM_FUNCTION CountUnicodeMappings
  302.     ENDIF
  303.  
  304. ;  Get a list of the available conversion mappings. 
  305. ;
  306. ; pascal OSStatus QueryUnicodeMappings(OptionBits iFilter, ConstUnicodeMappingPtr iFindMapping, ItemCount iMaxCount, ItemCount *oActualCount, UnicodeMapping oReturnedMappings[2147483647])
  307. ;
  308.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  309.         IMPORT_CFM_FUNCTION QueryUnicodeMappings
  310.     ENDIF
  311.  
  312. ;  Setup the fallback handler for converting Unicode To Text. 
  313. ;
  314. ; pascal OSStatus SetFallbackUnicodeToText(UnicodeToTextInfo iUnicodeToTextInfo, UnicodeToTextFallbackUPP iFallback, OptionBits iControlFlags, LogicalAddress iInfoPtr)
  315. ;
  316.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  317.         IMPORT_CFM_FUNCTION SetFallbackUnicodeToText
  318.     ENDIF
  319.  
  320. ;  Setup the fallback handler for converting Unicode To TextRuns. 
  321. ;
  322. ; pascal OSStatus SetFallbackUnicodeToTextRun(UnicodeToTextRunInfo iUnicodeToTextRunInfo, UnicodeToTextFallbackUPP iFallback, OptionBits iControlFlags, LogicalAddress iInfoPtr)
  323. ;
  324.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  325.         IMPORT_CFM_FUNCTION SetFallbackUnicodeToTextRun
  326.     ENDIF
  327.  
  328.  
  329.     ENDIF ; __UNICODE__ 
  330.  
  331.